package com.gitee.huxing.course.conc.conc01;

/**
 * @Description:
 * @ProjectName: JavaCourse
 * @Package: com.gitee.huxing.course.conc.cono01
 * @ClassName: ThreadB
 * @Author: huxing
 * @DateTime: 2021-08-20 上午9:50
 */
public class ThreadB implements Runnable{

    @Override
    public void run() {
        try {
            Thread.sleep(500L);
        } catch (Exception ex){
            ex.printStackTrace();
        }
        Thread currentThread = Thread.currentThread();
        String currentThreadName = currentThread.getName();
        System.out.println("这是线程的名字: " + currentThreadName);
        System.out.println("返回当前线程" + currentThreadName + "线程组的活跃数量: "
                + Thread.currentThread().getThreadGroup().activeCount());
        System.out.println("返回该线程" + currentThreadName + "的标识符:" + currentThread.getId());
        System.out.println("返回该线程" + currentThreadName + "的优先级:" + currentThread.getPriority());
        System.out.println("返回该线程" + currentThreadName + "的状态:" + currentThread.getState());
        System.out.println("返回该线程" + currentThreadName + "所属的线程组:" + currentThread.getThreadGroup());
        System.out.println("返回该线程" + currentThreadName + "是否处于活跃状态:" + currentThread.isAlive());
        System.out.println("返回该线程" + currentThreadName + "是否为守护线程:" + currentThread.isDaemon());
    }
}
